package com.jasic.comnt.protocol.bean;

import com.jasic.common.GlobalConstant;
import com.jasic.common.exception.HandleException;
import com.jasic.comnt.protocol.MessageCommon;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * User: Jasic
 * Date: 12-12-25
 */
public class LoginResp extends BaseResponse {

    private static Logger logger = LoggerFactory.getLogger(LoginResp.class);
    /**
     * 0:success 1:unsuccess
     */
    private int responseCode;

    public LoginResp(int responseCode) {
        super(new MessageCommon(GlobalConstant.CMD_LOGINRESP, GlobalConstant.LOGINRESP_LENGTH));
        this.responseCode = responseCode;

        super.initCheckNum();
    }

    public LoginResp(byte[] data)throws HandleException {
        super(data);
    }


    @Override
    protected byte[] getMsgByte() {
        byte[] b = new byte[GlobalConstant.LOGINRESP_LENGTH - MessageCommon.MSG_COMMON_LENGTH];
        b[0] = (byte) responseCode;
        return b;
    }


    @Override
    protected void setValues() {
        responseCode = super.msgByte[0];
    }

    public int getResponseCode() {

        return this.responseCode;
    }
}
